﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using COFE.Core;

namespace COFE.Web
{
    /// <summary>
    /// Template for generating Link, contain a number of macro (e.g. #id#).
    /// </summary>
    public class LinkTemplate
    {
        #region Constructor
        /// <summary>
        /// Constructor using MediaType, RelationType and Uri
        /// </summary>
        /// <param name="type"></param>
        /// <param name="rel"></param>
        /// <param name="uri"></param>
        public LinkTemplate(MediaType type, RelationType rel, string uriTemplate)
        {
            MediaType = type;
            RelationType = rel;
            UriTemplate = uriTemplate;
        }

        /// <summary>
        /// Constructor using MediaType, relation type string (for COFE Metadata) and Uri.
        /// </summary>
        /// <param name="type"></param>
        /// <param name="rel"></param>
        /// <param name="uri"></param>
        public LinkTemplate(MediaType type, string rel, string uriTemplate)
        {
            MediaType = type;
            RelationString = rel;
            UriTemplate = uriTemplate;
        }
        #endregion

        #region Methods



        #endregion

        #region Data

        private string _relStr = null;

        #endregion

        #region Public Properties

        /// <summary>
        /// Gets the type of what the link returns.
        /// </summary>
        public MediaType MediaType { get; set; }

        /// <summary>
        /// Gets the relation to hosting type (e.g. entry or search).
        /// </summary>
        public RelationType RelationType { get; set; }

        /// <summary>
        /// Gets the template of link target.
        /// </summary>
        public string UriTemplate { get; set; }

        /// <summary>
        /// Gets or sets relation string to hosting type (e.g. entry or search), you can set either Relation or RelationString.
        /// </summary>
        public string RelationString
        {
            get
            {
                return (RelationType == Web.RelationType.Property && _relStr != null) ? _relStr : RelationType.ToString();
            }
            set { _relStr = value; RelationType = Web.RelationType.Property; }
        }

        #endregion

    }

    public static class LinkTemplateExtension
    {

  

      
    }
}
